home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
021-030
/
amok21
/
popmenu
/
popmenudemo.mod
< prev
next >
Wrap
Text File
|
1993-11-04
|
4KB
|
136 lines
(*---------------------------------------------------------------------------
:Program. PopMenuDemo.mod
:Contents. Demonstriert die Benutzung des Moduls PopMenu
:Author. Bernd Preusing
:Address. Gerhardstr. 16 D-2200 Elmshorn
:Phone. 04121/22486
:Copyright. Public Domain
:Language. Modula-2
:Translator. M2Amiga V3.2e
:Support. siehe PopMenu.def
:History. V1.0 29-Apr-89
:Imports. PopMenu V1.0 (Preusing) BackDrop V1.0 (Preusing)
---------------------------------------------------------------------------*)
MODULE PopMenuDemo;
FROM SYSTEM IMPORT ADR;
FROM Arts IMPORT Terminate, CurrentLevel, Requester, TermProcedure;
FROM BackDrop IMPORT OpenBackDrop, BdRp, BdWindow, BdScreen;
FROM PopMenu IMPORT PopUpMenu, PopUpItem, StructPopUp, AddItem,
InitPopUp, PopUp, DisposePopUp,
NOITEMSELECTED, OUTSIDEWINDOW;
FROM Exec IMPORT GetMsg, ReplyMsg, WaitPort;
FROM Graphics IMPORT Move, SetAPen, Text, RectFill;
FROM Intuition IMPORT IDCMPFlags, IDCMPFlagSet, WindowPtr, menuUp, menuDown,
selectUp, selectDown,
WindowFlags, IntuiMessage, IntuiMessagePtr,
ModifyIDCMP, ScreenToFront, ActivateWindow;
FROM Str IMPORT Length;
CONST
DEPTH = 2;
VAR
StartLevel: INTEGER;
LeftMenu, RightMenu: PopUpMenu;
LeftItems: ARRAY[1..3] OF PopUpItem;
RightItems: ARRAY[1..5] OF PopUpItem;
PROCEDURE ButtonLoop;
PROCEDURE WriteL(s: ARRAY OF CHAR);
BEGIN
SetAPen(BdRp,1);
RectFill(BdRp,0,100,640,130);
Move(BdRp,10,115);
SetAPen(BdRp,2);
Text(BdRp,ADR(s),Length(s));
END WriteL;
VAR Action:INTEGER;
i: IntuiMessagePtr;
TempMsg: IntuiMessage;
BEGIN (* ButtonLoop *)
LOOP (* endlos *)
WaitPort(BdWindow^.userPort);
i:=GetMsg(BdWindow^.userPort);
TempMsg:=i^;
ReplyMsg(i);
WITH TempMsg DO
IF (class=IDCMPFlagSet{mouseButtons}) AND (code=menuDown) THEN
Action:=PopUp(RightMenu,BdWindow);
CASE Action OF
| 1: WriteL('Rechts 1');
| 2: WriteL('Rechts 2');
| 3: WriteL('Rechts 3');
| 4: WriteL('Rechts 4');
| 5: IF Requester(ADR('You want to'),ADR('QUIT?'),
ADR('Yes'),ADR('No')) THEN
Terminate(CurrentLevel());
ELSE
ScreenToFront(BdScreen); (* Workbench nach hinten *)
ActivateWindow(BdWindow);
END;
| OUTSIDEWINDOW: WriteL('OutSideWindow');
| NOITEMSELECTED: WriteL('No Item selected');
END;
ELSIF (class=IDCMPFlagSet{mouseButtons}) AND (code=selectDown) THEN
Action:=PopUp(LeftMenu,BdWindow);
CASE Action OF
| 1: WriteL('Links 1');
| 2: WriteL('Links 2');
| 3: WriteL('Links 3');
| OUTSIDEWINDOW: WriteL('OutSideWindow');
| NOITEMSELECTED: WriteL('No Item selected');
END;
ELSE
WriteL('unbekannter IDCMP');
END;
END; (* with TempMsg *)
END; (* endless loop *)
END ButtonLoop;
PROCEDURE Exit;
BEGIN
IF CurrentLevel()<=StartLevel THEN
DisposePopUp(LeftMenu);
DisposePopUp(RightMenu);
END
END Exit;
PROCEDURE Init;
BEGIN
StartLevel:=CurrentLevel();
TermProcedure(Exit);
OpenBackDrop(DEPTH,640,256-12,
ADR('PopUpMenuDemo © BP 4/89. Linke oder rechte Maustaste!'));
(* Rechtes Menü initialisieren: *)
StructPopUp(RightMenu,DEPTH,3,2);
AddItem(RightMenu,RightItems[1],ADR('Erster'), 1,1);
AddItem(RightMenu,RightItems[2],ADR('Zweiter'), 2,1);
AddItem(RightMenu,RightItems[3],ADR('Dritter'), 3,1);
AddItem(RightMenu,RightItems[4],ADR('Viertens oder was'),4,0);
AddItem(RightMenu,RightItems[5],ADR(' Ende'), 5,3);
RightItems[5].top:=5;
InitPopUp(RightMenu);
RightMenu.deactivate:=menuUp;
INCL(BdWindow^.flags,rmbTrap);
StructPopUp(LeftMenu,DEPTH,1,0);
AddItem(LeftMenu,LeftItems[1],ADR('11111111'), 1,2);
AddItem(LeftMenu,LeftItems[2],ADR('2222222222222222'),2,2);
AddItem(LeftMenu,LeftItems[3],ADR('333333'), 3,3);
InitPopUp(LeftMenu);
ModifyIDCMP(BdWindow,IDCMPFlagSet{mouseButtons});
END Init;
BEGIN
Init;
ButtonLoop;
END PopMenuDemo.